package com.qiudaozhang.service.impl;

import com.qiudaozhang.dto.ResponseCode;
import com.qiudaozhang.mapper.BasicsParameterDao;
import com.qiudaozhang.model.BasicsParameter;
import com.qiudaozhang.service.BasicsParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BasicsParameterServiceImpl implements BasicsParameterService {
    @Autowired
    private BasicsParameterDao basicsParameterDao;
    @Override
    public ResponseCode query() {
        ResponseCode code = new ResponseCode();
        List<BasicsParameter> list = basicsParameterDao.query();
        code.setData(list);
        code.setCode(0);
        return code;
    }

    @Override
    public void add(BasicsParameter basicsParameter) {
        basicsParameterDao.add(basicsParameter);
    }

    @Override
    public BasicsParameter queryById(Long id) {
        return basicsParameterDao.queryById(id);
    }

    @Override
    public void modify(BasicsParameter b) {
        basicsParameterDao.modify(b);
    }

    @Override
    public ResponseCode del(Long id) {
        ResponseCode code = new ResponseCode();
        Integer row = basicsParameterDao.del(id);
        if(row>0){
            code.setCode(ResponseCode.SUCCESS);
            code.setMsg("删除成功！！");
        }else{
            code.setCode(ResponseCode.FAIL);
            code.setMsg("删除失败！！");
        }
        return code;
    }
}
